﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace With_the_blank_page
{
    class SaveLoad
    {
       public class Save 
       {
           
           public static string ToLowCase(string input)
           {
               string result = "";
               foreach (char c in input) 
               {
                   result += Char.ToLower(c);
               }
               return result;
           }

            public static char MatrixFill(int number)
            {
                Dictionary<int, char> matrix = new Dictionary<int, char>();
                char a = 'a';
                char b = '0';
                for (int i = 1; i < 27; i++)
                {
                    matrix[i] = a;
                    a++;
                }
                for (int j = 27; j < 37; j++)
                {
                    matrix[j] = b;
                    b++;
                }
                
                    return matrix[number];
                
                
            }

            public static int MatrixFillB(char value)
            {
                Dictionary<char, int> matrix = new Dictionary<char, int>();
                char a = 'a';
                char b = '0';
                for (int i = 1; i < 27; i++)
                {
                    matrix[a] = i;
                    a++;
                }
                for (int j = 27; j < 37; j++)
                {
                    matrix[b] = j;
                    b++;
                }
                return matrix[value];
            }

           public static string Encript(string input)
            {
                string output = "";
                char a;
                for (int i = 0; i < input.Length; i++)
                {

                    a = input[i];
                    
                    int check = MatrixFillB(a) + (input.Length - i);
                    if (check > 36) 
                    { 
                    output += MatrixFill(check % 36);
                    }
                    else
                    {
                        output += MatrixFill(MatrixFillB(a) + (input.Length - i));
                    }
                }
              
                    return output;
            }

        }
       public class Load
       {
           public static string Decript(string input)
           {
               {
                   string output = "";
                   char a;
                   for (int i = 0; i < input.Length; i++)
                   {
                       a = input[i];
                       int check = Save.MatrixFillB(a) - (input.Length - i);
                       if (check < 0)
                       {
                           output += Save.MatrixFill(36 + check);
                       }
                       else
                       {
                           output += Save.MatrixFill(Save.MatrixFillB(a) - (input.Length - i));
                       }
                   }

                   return output;
               }
           }

           public static string ToUpCase(string input)
           {
               char firstC = input[0];
               input = Char.ToUpper(firstC) + input.Substring(1, input.Length - 1);
               return input;
           }

           public static string[] ReturnButtons(string input)
           {
               int sLength = Convert.ToInt32(input[0]);
               input = input.Substring(1, input.Length - 1);
               sLength = input.Length / sLength;
               string[] res = new string[sLength];
               for (int count = 0; count < input.Length; count += 3)
               {
                   int c3 = 0;
                   for (int c2 = 0; c2 < sLength; c2++)
                   {
                       res[c3] = input.Substring(count,sLength);
                   }
                   c3++;
               }
               return res;
           }
       }
    }
}
